﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="MvcDemo.Controllers" %>
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
	Home Page
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
	<h2>
		Demo of FormStateSaver in ASP.NET MVC.</h2>
	<p>
		This is a test form.<br />
		1) Try to fill out a few fields and submit. You should see the results.<br />
		2) Dont' click any buttons, wait 1 minute, and submit. You will be required to log
		on. After log on, your form post will be magically restored.<br />
		<br />
		Your Forms Authentication ticket will expire in <span id="counter">60</span> seconds...
		<br />
	</p>
	<form action="/Home/Submit" method="post">
		<table>
			<tr>
				<td>
					Some text:
				</td>
				<td>
					<%= Html.TextBox("Name") %>
					<%= ViewData["TextBoxTest"] %>
				</td>
			</tr>
			<tr>
				<td>
					A listbox:
				</td>
				<td>
					<%= Html.ListBox("List",
																 	new List<SelectListItem>()
																 		{
																 			new SelectListItem() { Text = "Option 1", Value = "Option 1" },
																			new SelectListItem() { Text = "Option 2", Value = "Option 2" }
																 		})%>
					<%= ViewData["ListBoxTest"] %>
				</td>
			</tr>
			<tr>
				<td>
					Some checkbox:
				</td>
				<td>
					<%= Html.CheckBox("Check") %>	<%= ViewData["CheckBoxTest"] %>
				</td>
			</tr>
		</table>
		<br />
		<input type="submit" value="Submit for testing!" />
	</form>

	<script language="javascript" type="text/javascript">
		var seconds = 60;
		document.getElementById("counter").innerHTML = '60';

		function display() {
			seconds -= 1;
			document.getElementById("counter").innerHTML = seconds;
			if (seconds > 0)
				setTimeout("display()", 1000);
		}
		display();
	</script>

</asp:Content>
